package cn.wolfcode.productdemo.product_fifter;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 延时发送消息
 * @Author: 伍家钰
 * @Date: 2020/9/4 11:38
 * @Version: 1.0
 */
@RestController
public class DelayedProductController {
    @Autowired
    private RocketMQTemplate template;

    @RequestMapping("delay")
    public String delayed(String msg) {
        MessageBuilder<String> builder = MessageBuilder.withPayload(msg);
        template.syncSend("01-delay", builder.build(), 5000, 2);
        System.out.println(msg);
        return "success";
    }
}
